// $Id: STSettings.cs 64 2008-05-06 18:29:47Z nvivo $

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.XPath;

namespace DBLGen.Plugins.Export
{
    public class STSettings : PluginSettings
    {
        private List<string> _templates;

        public List<string> Templates
        {
            get
            {
                if (_templates == null)
                    _templates = new List<string>();

                return _templates;
            }
            set
            {
                _templates = value;
            }
        }

        public override PluginSettings Clone()
        {
            STSettings settings = new STSettings();

            settings.Templates.AddRange(Templates);

            return settings;
        }

        protected override NameValueCollection SaveSettings()
        {
            NameValueCollection settings = new NameValueCollection();

            for (int i = 0; i < Templates.Count; i++)
            {
                settings["Template_" + i] = Templates[i];
            }

            return settings;
        }

        protected override void LoadSettings(NameValueCollection settings)
        {
            Templates.Clear();

            foreach (string key in settings.Keys)
            {
                if (key.StartsWith("Template_"))
                    Templates.Add(settings[key]);
            }
        }
    }
}
